(function ($) {
    var myStyle = null;
    var naviReady = false;
    //var mapFirstLoad = true;
    //var qMonth={n1:['01','02'],n2:['03','04'],n3:['05','06'],n4:['07','08'],n5:['09','10'],n6:['11','12'],n7:['13','14'],n8:['15','16'],n9:['17','18'],n10:['19','20'],n11:['21','22'],n12:['23','24','00']}
    var updateTime = {common:10000,moving:15000,quantity:30000};//更新时间
//    var _floorId = [2320336,2295735,2320340,2295838];//地图的楼层id数据
//    var _singleSizeId = [18.8,19,18,18.5];//单独地图的地图minSize(以floor为准)
//    var _multleSizeId = [17.6,18,17.2,17];//复选地图的地图minSize(以floor为准)
//    var _mapName = ['map4','map','map3','map2'];//地图wrap
    var _floorId = [2295735,2295838,2320340,2320336];//地图的楼层id数据
    var _singleSizeId = [19,18.5,18,18.8];//单独地图的地图minSize(以floor为准)
    var _multleSizeId = [18,17,17.2,17.6];//复选地图的地图minSize(以floor为准)
    var _mapName = ['map','map2','map3','map4'];//地图wrap
    var mainType = 'station'; //主要的类别 是岗位还是设备 station 岗位 eq 设备 task 作业 quantity 量化任务
    var mainTypeOld = 'station'; //主要的类别 是岗位还是设备 station 岗位 eq 设备 task 作业 quantity 量化任务
    var mainFloor = '1'; // 楼层
    var isStation = false //是否单个岗位（人员）
    var isMoving = false //是否移动轨迹时间是动态的
    var isAjax = false;
    var _date=new Date()
    var _accDate = _date.getFullYear()+'-'+(String(_date.getMonth()+1).length==1?"0"+String(_date.getMonth()+1):String(_date.getMonth()+1))+'-'+(String(_date.getDate()).length==1?"0"+String(_date.getDate()):String(_date.getDate()))//当天时间初始值
    var accWorkerInfo={
        userId:'',
        time:_accDate,
        movingTime:0,
        mstart:0,
        mend:0,
        stationType:'0',
        receiveNum:0,
        lostNum:0,
        successNum:0,
        
    }//当前选中人员的信息
    var RNum=1 //请求次数,地图渲染次数
    var AjaxData = [];//ajax获取的基础数据 
    var rightBarAcc = []//右侧分类提示选中的数据记录数组
    var rightBar = [] //右侧分类总体数据数组
    var eqRepair = false//只显示设备维修的按钮点击了
    var host_name = window.location.hostname =='localhost'?'10.87.140.198':window.location.hostname;
    var serverURL={
	    // basePath:"http://119.23.232.192:8081/Grid/",
	    // basePath:"http://10.87.140.204:8081/Grid/",
        // basePath:"http://10.87.140.198:8081/Grid/",
        basePath:'http://'+host_name+':8081/Grid/',
        stUrl:"map/user_status",
        eqUrl:"map/device_status",
        ststatusUrl:"map/user_info",
        stmoveUrl:"map/user_trail",
        searchWorker:"map/user_find",
        taskUrl:"map/work_status",
        quantityUrl:'map/get_quantification'
    }//服务端的URL
    var eqRepair = false//只显示设备维修的按钮点击了
    window.layers = {};
  
    var _hostName=''
    if(/10.78.153/.test(host_name)){
       _hostName ='http://10.78.153.165:58080'
    }else if(/10.87.140/.test(host_name)){
       _hostName = 'http://10.87.140.205:58080'
    }else if(/119.23.232/.test(host_name)){
         _hostName = ''
    }else{
         _hostName = ''
    }
    
    // 地图数据组合初始化 2017-12-11
    window.initMapData= function(floor,singleSize,multleSize,mapName){
       var mapCnt = []
       for(var i=0;i<floor.length;i++){
           var map = new NGR.View(mapName[i], {
                                appKey: "477fb7d9b9b0431fad887ea5af7fb703",
                                minZoom:multleSize[i],
                                server:_hostName,
                                scrollWheelZoom:"center"});
           var res = new NGR.DataSource({
                                appKey: "477fb7d9b9b0431fad887ea5af7fb703",
                                // server:'http://10.87.140.205:58080'
                                server:_hostName
           })
           var _tempObj = {map:map,
                           res:res ,
                           floor:floor[i],
                           layerGroup:NGR.layerGroup(),
                           linelayerGroup:NGR.layerGroup(),
                           markerData:[],
                           mapElm:mapName[i],
                           moveMarkers:{},
                           lastMovePoint:null,
                           firstMovePoint:null,
                           lastMovePointTime:0,
                           moveLine:null,
                           sigleSize:singleSize[i],
                           multleSize:multleSize[i]}
           mapCnt.push(_tempObj)
       }
       return mapCnt 
    }
    var mapCnt = initMapData(_floorId,_singleSizeId,_multleSizeId,_mapName)
    //地图请求 并 渲染地图图层
    window.loadPlanarGraph = function (opts) {
        var map=opts.map,res=opts.res;
        return res.requestPlanarGraph(opts.floor).then(function (layerInfo) {
            var lastLayer = null;
            //return false
            return NGR.IO.fetch({
                url: './style.json',
                onsuccess: JSON.parse
            }).then(function (style) {
                layers.frame = NGR.featureLayer(layerInfo, {
                    layerType: 'Frame',
                    styleConfig: style
                });
                layers.area = NGR.featureLayer(layerInfo, {
                    layerType: 'Area',
                    styleConfig: style
                });
                layers.annotation = NGR.featureLayer(layerInfo.Area, {
                    layerType: 'LogoLabel',
                    styleConfig: style
                });
                layers.facility = NGR.featureLayer(layerInfo.Facility, {
                    layerType: 'Facility',
                    styleConfig: style
                });

                layers.collision = NGR.layerGroup.collision({
                    margin: 3
                });
                layers.collision.addLayer(layers.annotation);
                layers.collision.addLayer(layers.facility);

                map.addLayer(layers.frame);
                map.addLayer(layers.area);
                map.addLayer(layers.collision);
                var _wanggearea = []
                if(mainType == 'quantity'){
                    $('#'+opts.mapElm).find('.lds-css').css('display','none')
                    _wanggearea = opts.markerData
                }else{
                    _wanggearea = wanggearea
                    //数据申请
                    if(RNum == mapCnt.length){
                        getBaseData();    
                    }else{
                        RNum ++    
                    }   
                }
                
                myStyle=style    
                /*var scale = NGR.control.scale();  // 创建比例尺
                map.addControl(scale);*/
                map.render();
                if($('.ngr-bottom.ngr-right').length != 0){
                    $('.ngr-bottom.ngr-right').remove()
                }
                if($('.ngr-top.ngr-left').length != 0){
                    $('.ngr-top.ngr-left').remove()
                }
                if($('.wangge_div'+opts.floor).length != 0 ){
                    $('.wangge_div'+opts.floor).remove()
                }
                $('<div class="wangge_div wangge_div'+opts.floor+'" style="">网格信息</div>').appendTo('#'+opts.mapElm).hide()
                var wang_div=$('.wangge_div'+opts.floor)
                wang_div.css({"width":"200px",
                            "min-height":"100px",
                            background:"#333333",
                            opacity:"0.9",
                            position:"absolute",
                            color:"#fff",
                            "border-radius":"5px",
                            "padding":"5px",
                            "box-shadow":"1px 1px 1px #000"
                            })
                          
                //console.log(wang_div)
                layers.area.eachLayer(function (layer) {
                    if(mainType == 'quantity'){
                        var _layerId = layer.feature.id
                        var _areaLayer = _wanggearea.filter(function(v){
                            return v.id == _layerId
                        })[0]
                        
                        if(_areaLayer && _areaLayer != undefined){
                            if(_areaLayer.status == '3'){
                                if(layer.feature.id != '2295763'){
                                    layer.setStyle({fillColor:'#de6029'})
                                }else{
                                    layer.setStyle({fillColor:'#52b4e0'})
                                }
                                //if(_areaLayer.areaData[0]){
                                //    var _data = _areaLayer.areaData[0];
                                //    var _thisTime = _data.endTime.slice(11,13)
                                //    var _nowTime = new Date().getHours().length != 1?new Date().getHours():'0'+new Date().getHours()
                                //    var _thisN = tempsHour(_thisTime)
                                //    var _nowN = tempsHour(_nowTime)                         
                                //    if(_thisN == _nowN && _data.userPost != null){
                                //        layer.setStyle({fillColor:'#52b4e0'})
                                //    }  
                                  //  layer.setStyle({fillColor:'#52b4e0'})
                                //}  
                            }else if(_areaLayer.status == '1'){
                                layer.setStyle({fillColor:'#0ebe34'})
                            }else if(_areaLayer.status == '2'){
                                layer.setStyle({fillColor:'#52b4e0'})
                            }    
                        }
                        
                          
                    }
                    //    layer.on('click', function (e) {
                    //        alert(e.target.feature.id)
                    //    })
                  
                  layer.on('mouseover', function (e) {
                    var wrap_ = $('#'+opts.mapElm)
                    var _areaId = e.target.feature.id 
                    var _wanggeWidth=wang_div.outerWidth(),_wanggeHeight=wang_div.outerHeight(),_offsetLeft=e.containerPoint.x,_offsetTop=e.containerPoint.y,_wrap=wrap_,_wrapWidth=_wrap.outerWidth(),_wrapHeight=_wrap.outerHeight(),_wrapOffsetLeft=_wrap.offset().left,_wrapOffsetTop=_wrap.offset().top
                    
                      if(e.containerPoint.y+_wanggeHeight-50 > _wrapHeight){
                          wang_div.css({bottom:10,top:'auto'}) 
                      }else if(e.containerPoint.y < 50 && e.containerPoint.y >0){
                          wang_div.css({bottom:'auto',top:10})
                      }else{
                          wang_div.css({bottom:'auto',top:e.containerPoint.y-50})
                      }
                      
                      if(e.containerPoint.x+_wanggeWidth+20 > _wrapWidth){
                          wang_div.css({left:_offsetLeft-_wanggeWidth-20,right:'auto'}) 
                      }else{
                          wang_div.css({left:_offsetLeft+20+'px',right:'auto'})
                      }
                    
                    var wangeAreaData=_wanggearea.filter(function(v){
                        return v.id == _areaId
                    })[0]
                    if(wangeAreaData && wangeAreaData != undefined){
                        var _tempCnt = areaInfoData(wangeAreaData) 
                        wang_div.html(_tempCnt).show()
                        
                    }else{
                        wang_div.hide()
                    }
                    //    if(_layerId == '2320341'){
                    //        var _tempCnt = areaInfoData({userPost:null,status:'3'})
                    //        wang_div.html(_tempCnt).show()    
                    //    }
                    if(mainType != 'quantity'){
                        e.target.setStyle({ fillColor: '#002b41',weight:2,color:'#53e306' });    
                    }else{
                        e.target.setStyle({weight:2,color:'#53e306' });
                    }
                    
                  });
                  layer.on('mouseout', function (e) {
                     if(mainType != 'quantity'){
                         e.target.setStyle({ fillColor: '#002031',weight:1,color:'#ffffff'}); 
                     }else{
                        e.target.setStyle({weight:1,color:'#ffffff' }); 
                     }
                    wang_div.hide()
                  });
                  
                });
		        //线上这里进行了包裹
                wang_div.on('mouseover',function(){
                      wang_div.show()
                })
                opts.wangDiv=wang_div
                $('#'+opts.mapElm).on('mouseout',function(e){
                  opts.wangDiv.hide()
                })
            }).fail(function (e) {
                return console.error(e, e.stack);
            });
        }).fail(function (e) {
            return console.error(e, e.stack);
        });
    }
    // 初始化
    for(var i=0;i<mapCnt.length;i++){ 
        loadPlanarGraph(mapCnt[i])   
    }
    //地图网格弹窗内容 2017-12-11
    window.areaInfoData = function(data){
        var wangeAreaData = data
        //console.log(wangeAreaData)
        var _tempCnt =''
        if(mainType != 'quantity'){
            _tempCnt += '<p class="wanggetit" style="margin-bottom:6px">网格名称：' + wangeAreaData.area +'（'+wangeAreaData.w_bianhao+'）'+' </p>'
            _tempCnt += '<p>作业部门：</p>'
            _tempCnt += '<p style="margin-bottom:3px">' + wangeAreaData.zuoyebumen+'</p>'
            _tempCnt += '<p>负责部门：</p>'
            _tempCnt += '<p>' + wangeAreaData.fuzeren+'</p>'    
        }else{
            if(wangeAreaData.status == 3){
                if(wangeAreaData.areaData && wangeAreaData.areaData.length>0 && wangeAreaData.areaData[0].userPost != null){
                        _tempCnt += '<p>最近完成巡视任务</p>'
                        for(var i=0;i<wangeAreaData.areaData.length;i++){
                            var _da=wangeAreaData.areaData[i]
                                _tempCnt += '<p>姓名：'+_da.userName+'</p>'
                                _tempCnt += '<p>岗位：'+_da.userPost+'</p>'
                                _tempCnt += '<p>部门：'+_da.userDep+'</p>'
                                _tempCnt += '<p>领取时间：'+_da.recieveTime+'</p>'
                                _tempCnt += '<p>巡视时间：'+_da.endTime+'</p>'    
                        }
                }else{
                    _tempCnt += '<p>无巡视人员接取任务</p>'      
                }  
            }else if(wangeAreaData.status == 1){
                _tempCnt += '<p>已接取巡视任务</p>'
                var _tempData = []
                for(var j=0;j<wangeAreaData.areaData.length;j++){
                    var _x = wangeAreaData.areaData[j].userName
                    var isOnly = _tempData.every(function(v){
                        return v.userName != _x
                    })
                    if(isOnly){
                        _tempData.push(wangeAreaData.areaData[j])
                    }
                }
                var _ef = _tempData.length >=5?5:_tempData.length;
                for(var i=0;i<_ef;i++){
                    var _da=_tempData[i]
                    _tempCnt += '<p>姓名：'+_da.userName+'</p>'
                    _tempCnt += '<p>岗位：'+_da.userPost+'</p>'
                    _tempCnt += '<p>部门：'+_da.userDep+'</p>'
                    _tempCnt += '<p>领取时间：'+_da.recieveTime+'</p>'
                }
            }else if(wangeAreaData.status == 2){
                _tempCnt += '<p>完成巡视任务</p>'
                var _da=wangeAreaData.areaData[0]
                _tempCnt += '<p>姓名：'+_da.userName+'</p>'
                _tempCnt += '<p>岗位：'+_da.userPost+'</p>'
                _tempCnt += '<p>部门：'+_da.userDep+'</p>'
                _tempCnt += '<p>领取时间：'+_da.recieveTime+'</p>'
                _tempCnt += '<p>巡视时间：'+_da.endTime+'</p>'
            }
           
        }
        return _tempCnt
    }
    //弹窗 鼠标操作每个点时弹窗以及操作
    window.setPopTips=function(type,ob,data,wangDiv){
        switch(type){
            case 'user':
                var _data=data
                var s = NGR.popup({closeButton: false, className: 's', keepInView: true})
                
                ob.on('mouseover', function (e) {
                    ob.openPopup()
                    wangDiv.css({opacity:0})
                })
                ob.on('click',function(e){
                    if(!isAjax){
                        //点击图标时进入详情页面，并加载a当前人员的 b当天的 c岗位的作业状态
                        var userid = ob.options.userId
                        $('.station_bar_right').removeClass('none')
                        $('.chartBar_right .ptypebar').remove()
                        $('.chartBar_right2').show()
                        $('.ptime').val(_accDate)
                        isStation = true
                        accWorkerInfo.userId =userid
                        accWorkerInfo.stationType ='0'
                        wangDiv.css({opacity:0.9})
                        $('.detailelm[data-rel=0]').addClass('active').siblings('.detailelm').removeClass('active')
                        mainType = 'userStation'
                        getBaseData()
                    }
                    
                })
                ob.on('mouseout',function(e){
                    ob.closePopup()
                    wangDiv.css({opacity:0.9})
                })
            break;
            case 'eq':case 'userS':case 'task':case 'userM':
                var _data=data
                ob.on('mouseover', function (e) {
                    ob.openPopup()
                    wangDiv.css({opacity:0})
                })
                ob.on('mouseout',function(e){
                    ob.closePopup()
                    wangDiv.css({opacity:0.9})
                })
            break;
        }
    }
    //获取数据
    window.getBaseData = function (opts){
        if(!isAjax){
            mainTypeOld = mainType
        }
        isAjax = true;
        $('.lds-css').css('display','block')
        $('.station_bar_right2').hide() //作业模块 时间段选择按钮 隐藏掉
        var url=serverURL.basePath+serverURL.stUrl;
        var _data ={_:Math.random()}
        if(mainType == 'station'){
            url = serverURL.basePath+serverURL.stUrl;
        }else if(mainType == 'eq'){
            url = serverURL.basePath+serverURL.eqUrl;
        }else if(mainType == 'task'){
            $('.station_bar_right2').show()
            url = serverURL.basePath+serverURL.taskUrl;
            _data={
                start:$('.starttime').val()?$('.starttime').val():'2017-11-20 00:00',//_accDate+' 00:00'
                end:$('.endtime').val()?$('.endtime').val():'2017-11-20 23:59'//_accDate+' '+_date.getHours()+':'+_date.getMinutes()
            }
        }else if(mainType == 'quantity'){
            url = serverURL.basePath+serverURL.quantityUrl
        }else if(mainType == 'userStation'){
            url = serverURL.basePath+serverURL.ststatusUrl
            _data={
                user_id:accWorkerInfo.userId,
                time:accWorkerInfo.time
            }
        }else if(mainType == 'userMoving'){
            $('.station_bar_right2').show()
            url = serverURL.basePath+serverURL.stmoveUrl;
            var _date=new Date()
            var _accDate = _date.getFullYear()+'-'+baseFn.formatDate(_date.getMonth()+1)+'-'+baseFn.formatDate(_date.getDate())
            var _accTime = baseFn.formatDate(_date.getHours())+':'+baseFn.formatDate(_date.getMinutes())
            if($('.endtime').val() != ''){

            }
            _data={
                user_id:accWorkerInfo.userId,
                start:$.trim($('.starttime').val()) != ''?$('.starttime').val():_accDate+' '+(Number(_date.getHours())-2 < 0?'00':_date.getHours()-2)+':00',
                end:$.trim($('.endtime').val()) != ''?$('.endtime').val():_accDate+' '+_accTime
            }
        }
        $.ajax({
            url: url,
            type: "POST",
            dataType: "json",
            data:_data,
            success: function (res) {
                if(mainType != mainTypeOld){
                    getBaseData()
                    return false
                }
                $('.chartBar_right').html('')
                $('.chartBar_right2').hide()
                rightBar = [];
                if(mainType != 'userMoving'){
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].lastMovePointTime=0
                        mapCnt[i].layerGroup.clearLayers(); //清除之前画上去的marker点
                        mapCnt[i].linelayerGroup.clearLayers(); //清除之前画上去的line点
                    }
                }

                if(mainType == 'station') {
                    //岗位人员
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].map.addLayer(mapCnt[i].layerGroup); 
                        mapCnt[i].map.addLayer(mapCnt[i].linelayerGroup); 
                    }
                    var markers = createMarkerLayers('user',res.data.data,['type','floor'])
                    setTypeList('user',markers)
                    addLayers('user',markers) 
                }else if(mainType == 'userStation'){
                    $('.chartBar_right2').show()
                    // 岗位人员具体人员的作业任务
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].map.addLayer(mapCnt[i].layerGroup); 
                        mapCnt[i].map.addLayer(mapCnt[i].linelayerGroup); 
                    }
                    var markers = createMarkerLayers('userS',res.data.data,['floor'])
                    setTypeList('userS',res.data.info)
                    addLayers('userS',markers) 
                }else if(mainType == 'userMoving'){
                    // 岗位人员具体人员的轨迹
                    $('.chartBar_right2').show()
                    var markers = createMarkerLayers('userM2',res.data.data,['floor'],{start:Date.parse(_data.start)/1000,end:Date.parse(_data.end)/1000+59})
                }else if(mainType == 'eq') {
                    // 设备
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].map.addLayer(mapCnt[i].layerGroup); 
                        mapCnt[i].map.addLayer(mapCnt[i].linelayerGroup); 
                    }
                    var markers = createMarkerLayers('eq',res.data.data,['type','floor','status'])
                    setTypeList('eq',markers)
                    addLayers('eq',markers) 
                }else if(mainType == 'task'){
                    // 作业任务
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].map.addLayer(mapCnt[i].layerGroup); 
                        mapCnt[i].map.addLayer(mapCnt[i].linelayerGroup); 
                    }
                    if(res.data){
                        var markers = createMarkerLayers('task',res.data,['type','floor'])
                        setTypeList('task',markers)
                        addLayers('task',markers) 
                    }
                }else if(mainType == 'quantity'){
                    // 量化
                    setTypeList('quantity')
                    for(var i=0;i<mapCnt.length;i++){
                        mapCnt[i].markerData = res.data;
                        loadPlanarGraph(mapCnt[i])
                    }
                }
            },
            complete:function(){
                isAjax = false;
            },
            error: function (res) {
                console.log('getBaseData output error')
            }
        })
    }

    //创建marker点图层 12-09
    window.createMarkerLayers=function(type,data,status,other){
        var _data = data,_status=status
        switch(type){
            case 'eq':case 'user':case 'userS':case 'task':
            //根据 status 传的字段组,对数据进行分层
            var _reData={};
            var moving = true
            for(var i=0;i<_data.length;i++){
                
                rightBar.push(_data[i].type)//右侧导航的数据rightBar
                //取得实际数据的分类总和
                var _typeName='',_typeNameArr=[]
                for(var j=0;j<_status.length;j++){
                    _typeNameArr.push(_data[i][_status[j]])
                }
                _typeName = _typeNameArr.join('@@')
                if(!_reData[_typeName]){
                    _reData[_typeName]= new NGR.layerGroup()
                }
                //根据每个数据生成marker
                if(_data[i].latlng[0] != '' || _data[i].latlng[1] != '' ){
                    //_type：类型 _markStatus：决定颜色和pop内容的状态 clsName=弹窗的className
                    var _type=type,_markStatus=_data[i].status || _data[i].type || _data[i].workStatus,clsName='s';
                    var _markerOpt={
                        icon: ngrIcon(_type,_markStatus),
                        riseOnHover: true
                    }
                    if(_type=='user'){
                        _markerOpt.userId=_data[i].userId
                    }else if(_type == 'userS' || _type == 'task'){
                        clsName='popstationstatus'
                    }
                    //生成marker
                    var marker = NGR.marker(_data[i].latlng,_markerOpt)
                    //生成弹窗内容
                    var popcontent = markerPopContent(_type, _markStatus, _data[i])
                    marker.bindPopup(popcontent, {className: clsName}).openPopup();
                }
                _reData[_typeName].addLayer(marker)                   
            }
            
            rightBar = baseFn.uniqueArr(rightBar)//更新右侧导航的数据rightBar
            return _reData            
            break;
            case 'userM2':
                var _startTime = other.start,_endTime=other.end;
                var _mapIds={}
                //清除不满足时间条件的点
                for(var m=0;m<mapCnt.length;m++){
                    mapCnt[m].firstMovePoint && mapCnt[m].firstMovePoint.setIcon(ngrIcon('userM','m'))
                    mapCnt[m].lastMovePoint && mapCnt[m].lastMovePoint.setIcon(ngrIcon('userM','m'))
                    mapCnt[m].moveLine && mapCnt[m].moveLine.setLatLngs([])
                    _mapIds[mapCnt[m].floor]=m
                    for(var n in mapCnt[m].moveMarkers){
                        if(n>_endTime || n<_startTime){
                            mapCnt[m].layerGroup.removeLayer(mapCnt[m].moveMarkers[n])
                            delete mapCnt[m].moveMarkers[n]
                        }
                    }
                    $('#'+mapCnt[m].mapElm).find('.lds-css').css('display','none')
                }
                var _reData={}
                //加入满足条件的点
                for(var i=0;i<_data.length;i++){
                    var _selfTime=Date.parse(_data[i].addtime)/1000
                    if(_data[i].latlng[0] == '' || _data[i].latlng[1] == ''){
                        continue;
                    }else{                       
                        if(!_reData[_data[i].floor]){
                            _reData[_data[i].floor]= {
                                points:[],
                                firstMoveTime:0,
                                lastMoveTime:0
                            }
                        }
                        if(_reData[_data[i].floor].firstMoveTime == 0){
                            _reData[_data[i].floor].firstMoveTime=_selfTime
                        }
                        _reData[_data[i].floor].lastMoveTime = _selfTime
                        _reData[_data[i].floor].points.push([Number(_data[i].latlng[0]),Number(_data[i].latlng[1])])
                    }
                    var marker = NGR.marker(_data[i].latlng,
                        {icon:ngrIcon('userM','m')});
                    //弹窗内容
                    var popcontent = markerPopContent('userM', 'normal', _data[i])
                    marker.bindPopup(popcontent,{className:'s'}).openPopup();
                    console.log(mapCnt[_mapIds[_data[i].floor]])
                    if(mapCnt[_mapIds[_data[i].floor]] && !mapCnt[_mapIds[_data[i].floor]].moveMarkers[_selfTime]){
                        mapCnt[_mapIds[_data[i].floor]].moveMarkers[_selfTime] = marker;
                        setPopTips('userM',mapCnt[_mapIds[_data[i].floor]].moveMarkers[_selfTime],null,mapCnt[_mapIds[_data[i].floor]].wangDiv)
                        mapCnt[_mapIds[_data[i].floor]].layerGroup.addLayer(mapCnt[_mapIds[_data[i].floor]].moveMarkers[_selfTime])
                    }
                }
                for(var j in _reData){
                    if(mapCnt[_mapIds[j]]){
                        if(mapCnt[_mapIds[j]].moveLine){
                            mapCnt[_mapIds[j]].moveLine.setLatLngs(_reData[j].points)
                        }else{
                            mapCnt[_mapIds[j]].moveLine = NGR.polyline(_reData[j].points, { color: '#26e8e8',lineCap:'round',lineJoin:'round',weight: 3,dashArray: [5, 10],arrow:false,radius: 0.6})
                            mapCnt[_mapIds[j]].linelayerGroup.addLayer(mapCnt[_mapIds[j]].moveLine)
                        }
                        mapCnt[_mapIds[j]].firstMovePoint = mapCnt[_mapIds[j]].moveMarkers[_reData[j].firstMoveTime]
                        mapCnt[_mapIds[j]].lastMovePoint = mapCnt[_mapIds[j]].moveMarkers[_reData[j].lastMoveTime]
                        mapCnt[_mapIds[j]].firstMovePoint.setIcon(ngrIcon('userM','b'))
                        mapCnt[_mapIds[j]].lastMovePoint.setIcon(ngrIcon('userM','e'))
                    }
                }   
            break;
            case 'userM':
                var _reData={}
                var _startTime = other.start,_endTime=other.end;
                for(var i=0;i<_data.length;i++){
                    var _selfTime=Date.parse(_data[i].addtime)/1000
                    accWorkerInfo.mend = _selfTime
                    if(_data[i].latlng[0] == '' || _data[i].latlng[1] == ''){
                        continue;
                    }else{
                        if(!_reData[_data[i].floor]){
                            _reData[_data[i].floor]= {
                                points:[],
                                markers:{},
                                firstMoveTime:0,
                                lastMoveTime:0
                            }
                        }
                        if(_reData[_data[i].floor].firstMoveTime == 0){
                            _reData[_data[i].floor].firstMoveTime=_selfTime
                        }
                        _reData[_data[i].floor].lastMoveTime = _selfTime
                        _reData[_data[i].floor].points.push([Number(_data[i].latlng[0]),Number(_data[i].latlng[1])])
                    }
                    if(_selfTime <= _endTime && _selfTime >= _startTime){
                        continue;
                    }
                    var marker = NGR.marker(_data[i].latlng,
                        {icon:ngrIcon('userM','m')});
                    //弹窗内容
                    var popcontent = markerPopContent('userM', 'normal', _data[i])
                    marker.bindPopup(popcontent,{className:'s'}).openPopup();
                    _reData[_data[i].floor].markers[_selfTime]=marker
                    _reData[_data[i].floor].lastEndTime=_selfTime
                }
                _reData.start=_startTime
                _reData.end=_endTime
                return _reData
            break;
        }
    }
    //设置右侧列表项目 12-09
    window.setTypeList = function(type,data){
        var _data = data
        var imgurlM='../lib/img/';
        switch(type){
            case 'user':
                //渲染右侧列表
                var _html = $('<ul class="dobtngroup ptypebar"></ul>')
                for(var m=0;m<rightBar.length;m++){
                    $('<li class="ptype" data-ptype="'+rightBar[m]+'"><img src="'+imgurlM+getImgName(rightBar[m])+'" width="46"><span class="">'+rightBar[m]+'</span>'+'</li>').appendTo(_html)
                }
                _html.appendTo('.chartBar_right')
                //更新右侧列表的按钮状态（选中与否）
                $('.ptypebar .ptype').each(function() {
                    var $this = $(this)
                    $this.removeClass("acc")
                    $this.find('span').removeClass('chartBarAct')
                    for(var i=0;i<rightBarAcc.length;i++){
                        if($this.data('ptype') == rightBarAcc[i]){
                            $this.addClass("acc")
                            $this.find('span').addClass('chartBarAct')
                        }
                    }
                })
                //事件绑定
                $('.ptypebar .ptype').click(function (e) {
                    var _val = $(this).data('ptype')
                    //判断右侧选中与否
                    var isExit = rightBarAcc.some(function(v){
                        return v == _val
                    })
                    if(isExit){
                        var _tempArr=rightBarAcc.filter(function(vs){
                        return vs !=_val
                        })
                        rightBarAcc = _tempArr
                        $(this).removeClass("acc")
                        $(this).find('span').removeClass('chartBarAct')
                    }else{
                        rightBarAcc.push(_val)
                        $(this).addClass("acc")
                        $(this).find('span').addClass('chartBarAct')
                    }
                    addLayers('user',_data);
                }) 
            break;
            case 'userS':
                var $rightBarWrap = $('.chartBar_right2')
                $('.chartBar_right').html('')
                $rightBarWrap.show()
                var _user = $.extend({},{userName:'',userId:'',loginName:'',userPost:'',depGroup:''},_data)
                if(accWorkerInfo.stationType == '1'){
                    $rightBarWrap.find('.nomove').hide()
                }else{
                    $rightBarWrap.find('.nomove').show()
                    $rightBarWrap.find('.userrecive span').text(_user.receiveNum)
                    $rightBarWrap.find('.usersuccess span').text(_user.successNum)
                    $rightBarWrap.find('.useroutpos span').text(_user.lostNum)
                }
                $rightBarWrap.find('.username span').text(_user.userName)
                $rightBarWrap.find('.userid span').text(_user.loginName)
                if(_user.userPost == '' || _user.userPost == undefined){
                    $rightBarWrap.find('.userposition span').text('无')       
                }else{
                    $rightBarWrap.find('.userposition span').text(_user.userPost)       
                }
                $rightBarWrap.find('.userdep span').text(_user.depGroup)
                //setStationDeTailType(data)
            break;
            case 'eq':
                //渲染右侧列表
                var _html = $('<div class="chartBar_right_list eqtypebar"></div>')
                $('<span class="onlyec">仅显示异常设备</span>').appendTo(_html)
                for(var j=0;j<rightBar.length;j++){
                    $('<span class="eqtype" data-eqtype="'+rightBar[j]+'">'+rightBar[j]+'</span>').appendTo(_html)
                }
                var tips = '<ul class="chartBar_exm"><li data-ptype="1"><img src="'+imgurlM+'eqok.png" width="" /><span>正常</span></li><li data-ptype="2"><img src="'+imgurlM+'eqcall.png" width="" /><span>报修</span></li><li data-ptype="3"><img src="'+imgurlM+'eqing.png" width="" /><span>维修</span></li><li data-ptype="4"><img src="'+imgurlM+'eqrecall.png" width="" /><span>验收</span></li></ul>'
                $(tips).appendTo(_html)
                _html.appendTo('.chartBar_right');
                //更新右侧列表的选中状态
                $('.eqtypebar .eqtype').each(function() {
                    var $this = $(this)
                    $this.removeClass('chartBarAct')
                    for(var i=0;i<rightBarAcc.length;i++){
                        if($this.data('eqtype') == rightBarAcc[i]){
                            $this.addClass('chartBarAct')
                        }
                    }
                })
                if(eqRepair){
                    $('.onlyec').addClass('chartBarAct')
                }
                
                $('.eqtypebar .eqtype').click(function (e) {
                    var $this = $(this)
                    var _val = $(this).data('eqtype')
                    var isNoAcc = rightBarAcc.every(function(v){
                        return v != _val
                    })
                    if(isNoAcc){
                        $this.addClass('chartBarAct')
                        rightBarAcc.push(_val)    
                    }else{
                        $this.removeClass('chartBarAct')
                        var _tempArr=rightBarAcc.filter(function(v){
                        return v !=_val
                        })
                        rightBarAcc = _tempArr
                    }
                    addLayers('eq',_data);
                })
                $('.onlyec').click(function(){
                    if($(this).hasClass('chartBarAct')){
                        $(this).removeClass('chartBarAct')
                        eqRepair = false
                    }else{
                        $(this).addClass('chartBarAct')
                        eqRepair = true
                    }
                    addLayers('eq',_data);
                })
            break;
            case 'task':
                var _html = $('<ul class="dobtngroup ptypebar"></ul>')
                //右侧数据渲染
                for(var i=0;i<rightBar.length;i++){
                    $('<li class="ptype" data-ptype="'+rightBar[i]+'" style="margin-top:1rem"><span class="">'+rightBar[i]+'</span>'+'</li>').appendTo(_html)
                }
                _html.appendTo('.chartBar_right')
                //右侧状态更新
                $('.ptypebar .ptype').each(function(){
                    var $this = $(this)
                    $this.removeClass("acc")
                    $this.find('span').removeClass('chartBarAct')
                    for(var i=0;i<rightBarAcc.length;i++){
                        if($this.data('ptype') == rightBarAcc[i]){
                            $this.addClass("acc")
                            $this.find('span').addClass('chartBarAct')
                        }
                    }
                })
                $('.ptypebar .ptype').click(function (e) {
                    rightBarAcc = []
                    var _val = $(this).data('ptype')
                    rightBarAcc.push(_val)
                    $('.ptypebar .ptype').each(function() {
                        var $this = $(this)
                        $this.removeClass("acc")
                        $this.find('span').removeClass('chartBarAct')
                        for(var i=0;i<rightBarAcc.length;i++){
                            if($this.data('ptype') == rightBarAcc[i]){
                                $this.addClass("acc")
                                $this.find('span').addClass('chartBarAct')
                            }
                        }
                    })
                    addLayers('task',_data);
                }) 
                addLayers('task',_data);
            break;
            case 'quantity':
                var tips = '<div class="chartBar_right_list quantypebar"><ul class="chartBar_exm"><li data-ptype="0"><p class="quanimg quanimg1"></p><span>待巡视</span></li><li data-ptype="2"><p class="quanimg quanimg2"></p><span>巡视中</span></li><li data-ptype="1"><p class="quanimg quanimg3"></p><span>已巡视</span></li></ul></div>'
                $(tips).appendTo('.chartBar_right')
            break;
        }
    }
    //根据rightbar的情况将marker图层加入到地图中 12-09
    window.addLayers=function(type,data){
        var _data=data;
        for(var i=0;i<mapCnt.length;i++){
            $('#'+mapCnt[i].mapElm).find('.lds-css').css('display','none')
            if(type != 'userM'){
                mapCnt[i].layerGroup.clearLayers(); //清除之前画上去的marker点
                mapCnt[i].linelayerGroup.clearLayers(); //清除之前画上去的line点
                
            }
            var _floor = mapCnt[i].floor
            if(type == 'eq'){
                var _type = rightBarAcc.length==0?rightBar:rightBarAcc
                var _status = ['正常','报修','维修','验收']
                if(eqRepair){
                    _status = ['报修','维修','验收']
                }
                for(var j=0;j< _type.length;j++){
                   for(var k=0;k<_status.length;k++){
                        var _tempName = _type[j] + '@@' + _floor
                        _tempName += '@@'+_status[k]
                        _data[_tempName] && mapCnt[i].layerGroup.addLayer(_data[_tempName])
                        _data[_tempName] &&  _data[_tempName].eachLayer(function(layer){
                            setPopTips('eq',layer,null,mapCnt[i].wangDiv)
                        }) 
                   }
                }
            }else if(type == 'user'){
                var _type = rightBarAcc.length==0?rightBar:rightBarAcc
                for(var k = 0;k<_type.length;k++){
                    var _tempName = _type[k] + '@@'+ _floor
                    _data[_tempName] && mapCnt[i].layerGroup.addLayer(_data[_tempName])                  
                    _data[_tempName] && _data[_tempName].eachLayer(function(layer){
                        setPopTips('user',layer,null,mapCnt[i].wangDiv)
                    }) 
                }
            }else if(type == 'userS'){
                _data[_floor] && mapCnt[i].layerGroup.addLayer(_data[_floor])  
                _data[_floor] && _data[_floor].eachLayer(function(layer){
                    setPopTips('userS',layer,null,mapCnt[i].wangDiv)
                }) 
            }else if(type == 'userM'){
                mapCnt[i].firstMovePoint && mapCnt[i].firstMovePoint.setIcon(ngrIcon('userM','m'))
                mapCnt[i].lastMovePoint && mapCnt[i].lastMovePoint.setIcon(ngrIcon('userM','m'))
                for(var m in mapCnt[i].moveMarkers){
                    if(!(m>accWorkerInfo.mstart && m<=accWorkerInfo.mend)){
                        
                        mapCnt[i].layerGroup.removeLayer(mapCnt[i].moveMarkers[m])
                        delete mapCnt[i].moveMarkers[m]
                        continue;
                    }
                    
                }
                if(_data[mapCnt[i].floor] && _data[mapCnt[i].floor].markers != {}){
                    
                    for(var n in _data[mapCnt[i].floor].markers){
                        mapCnt[i].moveMarkers[n] = _data[mapCnt[i].floor].markers[n]
                        mapCnt[i].layerGroup.addLayer(mapCnt[i].moveMarkers[n])
                        setPopTips('userM',mapCnt[i].moveMarkers[n],null,mapCnt[i].wangDiv)
                    }
                }
                if(_data[mapCnt[i].floor] && _data[mapCnt[i].floor].firstMoveTime !=0 && _data[mapCnt[i].floor].lastMoveTime !=0){
                    mapCnt[i].moveMarkers[_data[mapCnt[i].floor].firstMoveTime] && (mapCnt[i].firstMovePoint = mapCnt[i].moveMarkers[_data[mapCnt[i].floor].firstMoveTime])
                    mapCnt[i].moveMarkers[_data[mapCnt[i].floor].lastMoveTime] && (mapCnt[i].lastMovePoint = mapCnt[i].moveMarkers[_data[mapCnt[i].floor].lastMoveTime])
                }
                
                mapCnt[i].firstMovePoint && mapCnt[i].firstMovePoint.setIcon(ngrIcon('userM','b'))
                mapCnt[i].lastMovePoint && mapCnt[i].lastMovePoint.setIcon(ngrIcon('userM','e'))
                if(_data[mapCnt[i].floor] && _data[mapCnt[i].floor].points.length >=1){
                    var polyline = NGR.polyline(_data[mapCnt[i].floor].points, { color: '#26e8e8',lineCap:'round',lineJoin:'round',weight: 3,dashArray: [5, 10],arrow:false,radius: 0.6})
                    mapCnt[i].linelayerGroup.addLayer(polyline)
                }
            }else if(type == 'task'){
                var _type = rightBarAcc.length==0?rightBar:rightBarAcc
                for(var k = 0;k<_type.length;k++){
                    var _tempName = _type[k] + '@@'+ _floor
                    _data[_tempName] && mapCnt[i].layerGroup.addLayer(_data[_tempName])                  
                    _data[_tempName] && _data[_tempName].eachLayer(function(layer){
                        setPopTips('task',layer,null,mapCnt[i].wangDiv)
                    }) 
                }
            }
  
        }
        
    }
    //重新加载地图数据 2017-12-13
    window.reloadMap = function(type){
        RNum = 1
        var _status=type
        for(var i=0;i<mapCnt.length;i++){
            mapCnt[i].map.remove()   
        }
        if(mapCnt.length == 1 ){
            mapCnt= initMapData([mapCnt[0].floor],[mapCnt[0].sigleSize],[mapCnt[0].multleSize],[mapCnt[0].mapElm])
        }else{
            mapCnt = initMapData(_floorId,_singleSizeId,_multleSizeId,_mapName)

        }
        for(var i=0;i<mapCnt.length;i++){
            $('#'+mapCnt[i].mapElm).removeClass('none');
            if(_status !== 'no'){
                loadPlanarGraph(mapCnt[i])  
            }     
        } 
    }
    //定时器
    var timer = setInterval(function(){commonTimer()},updateTime.common)
    //定时函数
    function commonTimer(){
        if(!isAjax){
            // accWorkerInfo.receiveNum = 0;
            // accWorkerInfo.lostNum = 0;
            // accWorkerInfo.successNum = 0;
            
            // for(var i=0;i<mapCnt.length;i++){
            //     if(isStation){
            //         getDataWorkStation(mapCnt[i])
            //     }else{
            //         if(i == mapCnt.length-1 && mainType != 'quantity'){
            //             getBaseData(mapCnt[i])    
            //         }
            //     }     
            // }
            if(mainType == 'quantity'){
                reloadMap('no')
                getBaseData()
            }else{
                getBaseData()
            }
               
        }
    }
    //获取地图上坐标点和右边提示栏目中涉及到的图片的名称 12-11
    window.getImgName=function(ca){
        var _text = '';
        switch(ca){
            case "客运车间":
                _text = '1.png'
            break;
            case "售票车间":
                _text = '2.png'
            break;
            case "运转车间":
                _text = '3.png'
            break;
            case "房修车间":
                _text = '4.png'
            break;
            case "信息化车间":
                _text = '5.png'
            break;
            case "保洁车间":
                _text = '6.png'
            break;
            case "后勤车间":
                _text = '11.png'
            break;
            case "商服车间":
                _text = '7.png'
            break;
            case "行装车间":
                _text = '8.png'
            break;
            case "上水车间":
                _text = '9.png'
            break;
            case "机关":
                _text = '12.png'
            break;
            case "其他":
                _text = '10.png'
            break;
            default:
                _text = '10.png'
            break;
        }
        return _text
    }
    //地图marker 样式 12-11
    function ngrIcon(page, type) {
        var _baseResourcePath = '../lib/img/'
        var _type = {
            iconUrl: _baseResourcePath+'marker-location.png',
            iconSize: [20, 20]
        };
        switch (page) {
            case 'user':case 'userS':
                switch (type) {
                    case "保洁车间":case "客运车间":case "房修车间":case "信息化车间":case "运转车间":case "机关干部":case "其他":case "售票车间":case "上水车间":case "机关":case "后勤车间":case "商服车间":case '行装车间':
                        _type = {
                            iconUrl: _baseResourcePath+getImgName(type),
                            iconSize: [58, 58]
                        }
                    break;
                    case '完成':
                        _type = {
                            iconUrl: _baseResourcePath+'ok.png',
                            iconSize:[30,30]    
                        }
                    break;
                    case '脱岗':case '未完成':
                        _type = {
                            iconUrl: _baseResourcePath+'fail.png',
                            iconSize:[30,30]    
                        }
                    break;
                    case '进行中':
                        _type = {
                            iconUrl: _baseResourcePath+'ing.png',
                            iconSize:[30,30]    
                        }
                    break;
                    default:
                        _type = {
                            iconUrl: _baseResourcePath+'marker-location.png',
                            iconSize: [20,20]
                        }
                    break;
                }
            break;
            case 'eq':
                switch (type) {
                    case '正常':
                        _type = {
                            iconUrl: _baseResourcePath+'eqok.png',
                            iconSize: [34, 34]
                        }
                        break;
                    case '报修':
                        _type = {
                            iconUrl: _baseResourcePath+'eqcall.png',
                            iconSize: [34,34]
                        }
                        break;
                    case '维修':
                        _type = {
                            iconUrl: _baseResourcePath+'eqing.png',
                            iconSize: [34, 34]
                        }
                        break;
                    case '验收':
                        _type = {
                            iconUrl: _baseResourcePath+'eqrecall.png',
                            iconSize: [34,34]
                        }
                        break;
                    default:
                        _type = {
                            iconUrl: _baseResourcePath+'eqok.png',
                            iconSize: [34, 34]
                        }
                        break;
                }
            break;
            case 'userM':
                switch(type){
                    case 'b':
                        _type = {
                            iconUrl: _baseResourcePath+'mob2.png',
                            iconSize:[30,30]    
                        }
                    break;
                    case 'e':
                        _type = {
                            iconUrl: _baseResourcePath+'moe2.png',
                            iconSize:[30,30]   
                        }
                    break;
                    case 'm':
                        _type = {
                            iconUrl: _baseResourcePath+'mo2.png',
                            iconSize:[18,18]  
                        }
                    break;
                    default:
                    break;
                }
            break;
            case 'task':
                switch(type){  
                    case '0':case 0:case '未完成'://未完成
                        _type = {
                            iconUrl: _baseResourcePath+'t0.png',
                            iconSize:[28,28]    
                        }
                    break;
                    case '2':case 2:case '完成'://完成
                        _type = {
                            iconUrl: _baseResourcePath+'t2.png',
                            iconSize:[28,28]   
                        }
                    break;
                    case '1':case 1:case '进行中'://进行中 接受
                        _type = {
                            iconUrl: _baseResourcePath+'t1.png',
                            iconSize:[28,28]   
                        }
                    break;
                    default:
                    break;
                }
            break;
        }
        return NGR.icon(_type)
    }
    //弹窗内容 12-08
    function markerPopContent(page, type, data) {
        var _cnt = "<p>这是一个弹窗</p>"
        switch (page) {
            case 'user':
                _cnt = '<p>姓名：' + data.userName +' </p>'
                _cnt +='<p>岗位：'
                if(data.userPost !=undefined && data.userPost !=''){
                    _cnt +=data.userPost    
                }else if(data.Title !=undefined && data.Title !=''){
                    _cnt +=data.Title   
                }else{
                    _cnt +='职工' 
                } 
                _cnt +='</p>'
                _cnt +='<p>部门：'+data.depName+'</p>';
            break;
            case 'eq':
                switch (type) {
                    case '正常':
                        _cnt = '<p>设备名称：'+data.name+'</p>'+'<p>设备类别：'+data.type+'</p>'+'<p>设备状态：'+data.status+'</p>';
                    break;
                    case '报修':
                        _cnt = '<p>设备名称：'+data.name+'</p>'+'<p>设备类别：'+data.type+'</p>'+'<p>设备状态：'+data.status+'</p>';
                    break;
		            case '验收':
                        _cnt = '<p>设备名称：'+data.name+'</p>'+'<p>设备类别：'+data.type+'</p>'+'<p>设备状态：'+data.status+'</p>';
                    break;
                    case '维修':
                        _cnt = '<p>设备名称：'+data.name+'</p>'+'<p>设备类别：'+data.type+'</p>'+'<p>设备状态：'+data.status+'</p>';
                    break;
                    default:
                    break;
                }
            break;
            case 'userM':
                switch(type){
                    case 'normal':  
                        _cnt = '<p>时间：'+ data.addtime + '</p>'
                    break;
                }
            break;
            case 'userS':
                switch(type){
                    case '完成':  
                        _cnt = '<p class="popstationp">工作名称：' + data.workName +'<p class="popstationp">工作状态：' + data.workStatus +'</p>'+'<p class="popstationp">接受时间：'+data.taskReceiveTime+'</p>'+'<p class="popstationp">完成时间：'+data.taskOverTime+'</p>'
                    break;
                    case '脱岗':case '未完成':  
                        _cnt = '<p class="popstationp">工作名称：' + data.workName +'<p class="popstationp">工作状态：' + data.workStatus +'</p>'+'<p class="popstationp">接受时间：'+data.taskReceiveTime+'</p>'+'<p class="popstationp">完成时间：'+data.taskOverTime+'</p>'
                    break;
                    case '进行中':  
                        _cnt = '<p class="popstationp">工作名称：' + data.workName +'<p class="popstationp">工作状态：' + data.workStatus +'</p>'+'<p class="popstationp">接受时间：'+data.taskReceiveTime+'</p>'+'<p class="popstationp">完成时间：'+data.taskOverTime+'</p>'
                    break;
                }
            break;
            case 'task':
                switch(type){
                    case '0':case 0: case '未完成': //未完成 
                        _cnt = '<p class="popstationp">任务名称：' + data.taskName+'</p>'
                        _cnt += '<p class="popstationp">作业人员：' + data.name+'</p>'
                        _cnt += '<p class="popstationp">作业岗位：'+data.post+'</p>'
                        _cnt += '<p class="popstationp">接受时间：'+data.receiveTime+'</p>'
                        _cnt += '<p class="popstationp">完成时间：'+data.overTime + '</p>'
                        _cnt += '<p class="popstationp">任务状态：<span style="color:#f00">未完成</span></p>'
                    break;
                    case '2':case 2:case '完成': //完成   
                        _cnt = '<p class="popstationp">任务名称：' + data.taskName +'</p>'
                        _cnt += '<p class="popstationp">作业人员：' + data.name+'</p>'
                        _cnt += '<p class="popstationp">作业岗位：'+data.post+'</p>'
                        _cnt += '<p class="popstationp">接受时间：'+data.receiveTime+'</p>'
                        _cnt += '<p class="popstationp">完成时间：'+data.overTime + '</p>'
                        _cnt += '<p class="popstationp">任务状态：<span style="color:#1baaf5">完成</span></p>'
                    break;
                    case '1':case 1:case '进行中': //进行中 接受  
                        _cnt = '<p class="popstationp">任务名称：' + data.taskName +'</p>'
                        _cnt += '<p class="popstationp">作业人员：' + data.name+'</p>'
                        _cnt += '<p class="popstationp">作业岗位：'+data.post+'</p>'
                        _cnt += '<p class="popstationp">接受时间：'+data.receiveTime+'</p>'
                        _cnt += '<p class="popstationp">完成时间：'+data.overTime + '</p>'
                        _cnt += '<p class="popstationp">任务状态：<span style="color:#44f703">任务执行中</span></p>'
                    break;
                }
            break;
        }
       
        return _cnt
    }
    //切换楼层
    $('.charLitBox').on('click', function () {
        if(!isAjax){
            accWorkerInfo.receiveNum = 0
            accWorkerInfo.successNum = 0
            accWorkerInfo.lostNum = 0
            var text = $('.chartBarFirstText').text();
            var thisText = $(this).text();
            $('.chartBarFirstText').text(thisText);
            $(this).text(text);
            $('.chartSlide').slideToggle();
            rightBarAcc=[]
            eqRepair=false
            for(var i=0;i<mapCnt.length;i++){
                mapCnt[i].map.clear()
                if (thisText == "二层") {
                    mainFloor = 3
                    mapCnt[i].map.setMinZoom(18.5);
                } else if (thisText == "一层") {
                    mainFloor = 1
                    mapCnt[i].map.setMinZoom(19);
                } else if (thisText == "站台") {
                    mainFloor = 2
                    mapCnt[i].map.setMinZoom(18.2);
                } else if (thisText == "通道"){
                    mainFloor = 0
                    mapCnt[i].map.setMinZoom(18.8);
                }
                mapCnt[i].layerGroup.clearLayers()
                mapCnt[i].linelayerGroup.clearLayers()
                mapCnt[i].lastMovePointTime=0;
                mapCnt[i].lastMovePoint=null; 
                mapCnt[i].floor=_floorId[mainFloor];
                loadPlanarGraph(mapCnt[i])    
            } 
        }
        return false;
    });
    //切换岗位/设备/作业/量化任务 2017-12-11
    $('.chartBar').on('click', function () {
        if(!isAjax){
        var _oldMainType = mainType;
        mainType=$(this).data('val')
        if(_oldMainType != mainType){
            //页面及右侧初始化
            $('.chartBar_right').html('')
            rightBar=[]
            rightBarAcc=[]
            $(this).addClass('chartBarAct').siblings('.chartBar').removeClass('chartBarAct');    
            $('.station_bar_right3').addClass('none')
            //
            if(mainType == 'quantity'){
                $('.stateName').text('量化任务')
                $('.station_bar_right3').removeClass('none')
                reloadMap('no')
                getBaseData()
                clearInterval(timer)
                timer = setInterval(function(){commonTimer()},updateTime.quantity)
            }else if(mainType == 'station'){
                $('.stateName').text('岗位')
            }else if(mainType == 'eq'){
                eqRepair=false
                $('.stateName').text('设备')
            }else if(mainType == 'task'){
                $('.stateName').text('作业')
                $('.starttime').val(_accDate+' 00:00')
                $('.endtime').val(_accDate+' '+_date.getHours()+':'+(String(_date.getMinutes()).length == 1?'0'+ String(_date.getMinutes()):_date.getMinutes()))
            }
            //由量化任务/轨迹 变成 其他非重新渲染地图的功能区
            if((mainType != 'quantity' && _oldMainType == 'quantity') || (mainType != 'userMoving' && mainType != 'quantity' && _oldMainType == 'userMoving')){
                reloadMap()
                clearInterval(timer)
                $('.station_bar_right3').addClass('none')
                timer = setInterval(function(){commonTimer()},updateTime.common)
                $('.stationgroup').val('0');
            }
            getBaseData()
        }       
        }
        
    });
    //4层同显 切换 单页面 2017-12-11
    $('.floorcnt').each(function(e){
        $(this).click(function(){
            
            RNum = 1;
            rightBar = [];
            var $this = $(this)
            var _ids = Number($this.data('val'))
            
            for(var i=0;i<mapCnt.length;i++){
                if(i != _ids){
                    $('#'+mapCnt[i].mapElm).addClass('none')   
                }else{
                    $('#'+mapCnt[i].mapElm).css({width:'100%',height:'100%','border-width':"0px"})                
                }
                mapCnt[i].map.remove();    
            }
            mapCnt = initMapData([_floorId[_ids]],[_singleSizeId[_ids]],[_multleSizeId[_ids]],[_mapName[_ids]])            
            $('.floorinfowrap').addClass('none')
            if(mainType != 'quantity' || mainType != 'userMoving'){
                loadPlanarGraph(mapCnt[0])    
            }else{ 
                getBaseData()
            }
            mapCnt[0].map.setMinZoom(mapCnt[0].sigleSize)
            $('.changeTypeBar').removeClass('none')
        })
    })
    //单页面 切换 4层同显 2017-12-11
    $('.changeTypeBar').on('click',function(){
        // accWorkerInfo.receiveNum = 0
        // accWorkerInfo.successNum = 0
        // accWorkerInfo.lostNum = 0
        $(this).addClass('none')
        mapCnt[0].map.remove();
        $('#'+mapCnt[0].mapElm).css({width:'50%',height:'50%','border-width':"1px"});
        
        mapCnt = initMapData(_floorId,_singleSizeId,_multleSizeId,_mapName)
        for(var i=0;i<mapCnt.length;i++){
            $('#'+mapCnt[i].mapElm).removeClass('none');
            if(mainType != 'quantity'){
                loadPlanarGraph(mapCnt[i])    
            }else{
                getBaseData()
            }
            
        }
        $('.floorinfowrap').removeClass('none')
    })
    for(var j=0;j<mapCnt.length;j++){
        mapCnt[j].map.on('click',function(e){
            $('#lats').val(e.latlng.lat)
            $('#lngs').val(e.latlng.lng)
            console.log(e)
            console.log(e.latlng.lat)
            console.log(e.latlng.lng)
        })    
    }
    //人员详情的任务和轨迹切换
    $('.detailelm').on('click',function(){
        var _rel = $(this).data('rel')
        $(this).addClass('active')
        $(this).siblings('.active').removeClass('active')
        if(_rel == '0'){
            if(mainType == 'userMoving'){
                reloadMap()
                clearInterval(timer)
                timer = setInterval(function(){commonTimer()},updateTime.common)    
            }
            mainType = 'userStation'
            // getBaseData()
             
        }else if(_rel == '1'){
            if(mainType == 'userMoving'){
                return false
            }
            mainType = 'userMoving'
            $('.starttime').val(_accDate+' '+(Number(_date.getHours())-2 < 0?'00':_date.getHours()-2)+':00')
            $('.endtime').val(_accDate+' '+_date.getHours()+':'+(String(_date.getMinutes()).length == 1?'0'+ String(_date.getMinutes()):_date.getMinutes()))
            for(var i=0;i<mapCnt.length;i++){
                mapCnt[i].lastMovePointTime=0
                mapCnt[i].layerGroup.clearLayers(); //清除之前画上去的marker点
                mapCnt[i].linelayerGroup.clearLayers(); //清除之前画上去的line点
            }
            getBaseData()
            clearInterval(timer)
            timer = setInterval(function(){commonTimer()},updateTime.moving) 
        }else if(_rel == '2'){
            $('.station_shaow_box').show();
            $('.resulttable').html('')
            $('.container_map').hide();
            $('.findtime').datetimepicker({
                lang:'ch',
                format:'Y-m-d',
                timepicker: false,
                dayOfWeekStart : 1, //从星期一开始
                value:_accDate,
                maxDate:'+1970/01/01'
            });
        }
    })
    $('.starttime').datetimepicker({
        lang:'ch',
        format:'Y-m-d H:i',
        timepicker: true,
        dayOfWeekStart : 1, //从星期一开始
        //value:_accDate+' '+_date.getHours()+':00',
        step:30,
        maxDate:'+1970/01/01'
    });
    $('.endtime').datetimepicker({
        lang:'ch',
        format:'Y-m-d H:i',
        timepicker: true,
        step:30,
        dayOfWeekStart : 1, //从星期一开始
        //value:_accDate+' '+_date.getHours()+':'+_date.getMinutes(),
        maxDate:'+1970/01/01'
    });
    //查询 个人 岗位详情 的时间参数 2017-12-11
    $('.ptime').datetimepicker({
        lang:'ch',
        format:'Y-m-d',
        timepicker: false,
        dayOfWeekStart : 1, //从星期一开始
        value:_accDate,
        maxDate:'+1970/01/01',
        monthChangeSpinner:false
    });
    $('.ptime').on('change',function(){
        accWorkerInfo.time = $(this).val()
        getBaseData()
    })
    //查询盒子
    $('.station_bar_find').on('click',function(){
        $('.station_shaow_box').show();
        $('.resulttable').html('')
        $('.container_map').hide();
        $('.findtime').datetimepicker({
            lang:'ch',
            format:'Y-m-d',
            timepicker: false,
            dayOfWeekStart : 1, //从星期一开始
            value:_accDate,
            maxDate:'+1970/01/01'
        });
    })
    function common_request(d){
        //var url="<?php echo site_url("quantification/index");?>?inajax=1&r="+Math.random();
        var url=serverURL.basePath+serverURL.searchWorker;
        var _data = {
            user_name:$('input[name=aname]').val(),
            user_account:$('input[name=anum]').val(),
            time:$('input[name=atime]').val(),
            inajax:1
        };
        if(d && d != undefined){
            _data.page = d
        }
        $.ajax({
            type: "post",
            url: url ,
            data: _data,
            cache:false,
            dataType:"json",
            //async:false,
            success: function(res){
                //if(msg.resultcode == 1){
                    //列表
                    var list = res.data;
                    var pagebar = 1
                    var pageCount = 1;
                    var shtml='';
                    $(".resulttable").html('');
                    $('.M-box1').html('')
                    if(list && list.length>0){
                        pageCount = Math.ceil(list.length/5);
                        shtml='';
                        for(var i=0;i<list.length;i++){
                            shtml+=' <tr class="shaow_detail_title count_tr">';
                            shtml+='<td class="">'+list[i]['user_name']+'</td>';
                            shtml+='<td class="">'+list[i]['user_account']+'</td>';
                            if(list[i]['post_name'] != '' && list[i]['post_name'] != undefined && list[i]['post_name'] != null){
                                shtml+='<td class="">'+list[i]['post_name']+'</td>';    
                            }else{
                                shtml+='<td class="">职工</td>'; 
                            }
                            shtml+='<td class="">'+list[i]['department_name']+'</td>';
                            shtml+='<td class="">'+list[i]['status']+'</td>';
                            shtml+='<td class="">'+'<a href="javascript:void(0)" class="workerdbtn" data-val="'+list[i]['user_id']+'">查询</a>'+'</td>';
                            shtml+='</tr>';
                        }
                        console.log(i)
                        $(".resulttable").html(shtml);
                        
                        $('.M-box1').pagination({
                            totalData:pageCount,
                            showData:1,
                            current:d,
                            coping:true,
                            callback:function(e){
                                common_request(e.getCurrent())
                            }
                        });
                    }else{
                        $(".resulttable").html("<tr><td colspan='6'>没有数据！</td></tr>");
                    }
                //}
            },
            error:function(){
                alert('服务器繁忙请稍后');
            }
        });
    }
    $('body').on("click",".shaowSubmit",function(){
        common_request()    
    })
    window.ajax_data = function(d){
        common_request(d)
    }
    //按人头查询详情
    $('body').on("click",".workerdbtn",function(e){
            var _val = $(this).data('val')
            $('.station_shaow_tit').click()
            accWorkerInfo.userId=_val
            accWorkerInfo.time=$('.findtime').val()   
            $('.ptime').val(accWorkerInfo.time)
            $('.detailelmuser').trigger('click') 
    })
    //作业模块 点击查询按钮
    $('body').on("click",".newBtu",function(e){
        getBaseData()
    })
    //岗位模块 detail 时 右上角的 查询 按钮
    $('.station_shaow_tit').on('click',function(){
        $('.station_shaow_box').hide();
        $('.container_map').show();
    })
    //刷新按钮（目前是巡视任务刷新）
    $('.station_bar_right3').on('click',function(){
        if(mainType == 'quantity'){
            reloadMap('no') 
            getBaseData()    
        }
        
    })
/*
    $('#sel').on('change',function() {
        var _val = $(this).val() 
        if(accWorkerInfo.stationType != _val){
            accWorkerInfo.successNum=0;
            accWorkerInfo.receiveNum=0;
            accWorkerInfo.lostNum=0;
            accWorkerInfo.stationType=_val
            for(var i=0;i<mapCnt.length;i++){
                if(isMoving == true){
                    mapCnt[i].map.remove();
                }else{
                    mapCnt[i].lastMovePoint=null;
                    mapCnt[i].lastMovePointTime=0;
                    mapCnt[i].linelayerGroup.clearLayers();
                    mapCnt[i].layerGroup.clearLayers();
                    getDataWorkStation(mapCnt[i])       
                }
                 
            }
            if(isMoving == true){
                if(mapCnt.length == 1 ){
                    mapCnt= initMapData([mapCnt[0].floor],[mapCnt[0].sigleSize],[mapCnt[0].multleSize],[mapCnt[0].mapElm])
                }else{
                    mapCnt = initMapData(_floorId,_singleSizeId,_multleSizeId,_mapName)
                       
                }
                for(var i=0;i<mapCnt.length;i++){
                        $('#'+mapCnt[i].mapElm).removeClass('none');
                        loadPlanarGraph(mapCnt[i])
                    } 
                isMoving = false
            }
            if(accWorkerInfo.stationType == '1'){
                clearInterval(timer)
                timer = setInterval(function(){commonTimer()},updateTime.moving) 
            }
            
        }       
    })
*/
/*
    //右侧 岗位任务状态和轨迹 2017-12-11
    window.setStationDeTailType=function(data){
        var _data = data,$rightBarWrap = $('.chartBar_right2')
        $('.chartBar_right').html('')
        $rightBarWrap.show()
        var _user = $.extend({},{userName:'',userId:'',loginName:'',userPost:'',depGroup:''},_data)
        if(accWorkerInfo.stationType == '1'){
            $rightBarWrap.find('.nomove').hide()
        }else{
            $rightBarWrap.find('.nomove').show()
            $rightBarWrap.find('.userrecive span').text(_user.receiveNum)
            $rightBarWrap.find('.usersuccess span').text(_user.successNum)
            $rightBarWrap.find('.useroutpos span').text(_user.lostNum)
        }
        $rightBarWrap.find('.username span').text(_user.userName)
        $rightBarWrap.find('.userid span').text(_user.loginName)
        if(_user.userPost == '' || _user.userPost == undefined){
            $rightBarWrap.find('.userposition span').text('无')       
        }else{
            $rightBarWrap.find('.userposition span').text(_user.userPost)       
        }
        $rightBarWrap.find('.userdep span').text(_user.depGroup)
    }
*/
/* 
    //弹窗 鼠标操作设备时的弹窗
    window.setPopTipsEQ = function (ob, data,wangDiv) {
        var _data=data
        ob.on('mouseover', function (e) {
            ob.openPopup()
            wangDiv.css({opacity:0})
        })
         ob.on('mouseout',function(e){
            ob.closePopup()
            wangDiv.css({opacity:0.9})
        })
    }
    //弹窗 鼠标操作某一个岗位的具体作业状况点时弹窗
    window.setPopTipsSTStatus=function(ob,data,wangDiv){
        var _data=data
        ob.on('mouseover',function(e){
            ob.openPopup()
            wangDiv.css({opacity:0})
        })
        ob.on('mouseout',function(e){
            ob.closePopup()
            wangDiv.css({opacity:0.9})
        })
    }
    //弹窗 鼠标操作某一个岗位的具体行动轨迹时的弹窗
    window.setPopTipsMove=function(ob,data,wangDiv){
         var _data=data
         ob.on('mouseover',function(e){
            ob.openPopup()
            wangDiv.css({opacity:0})   
        })
        ob.on('mouseout',function(e){
            ob.closePopup()
            wangDiv.css({opacity:0.9})
        })
    }
    //弹窗 鼠标操作作业时的弹窗
    window.setPopTipsTask = function (ob, data,wangDiv) {
        var _data=data
        ob.on('mouseover', function (e) {
            ob.openPopup() 
            wangDiv.css({opacity:0})
        })
         ob.on('mouseout',function(e){
            ob.closePopup()
            wangDiv.css({opacity:0.9})
        })
    }
*/
/*
    //生成作业点添加到地图
    window.addMarkersTask = function (opts) {
        opts.layerGroup.clearLayers()//清除之前画上去的marker点
        opts.linelayerGroup.clearLayers()//清除之前画上去的line点
        var _accTrain = rightBarAcc[0]
        var _points=opts.markerData,points =[]
        for(var k=0;k<_points.length;k++){
            if(_points[k].train == _accTrain){
                points = [_points[k]]
            }
        }
        if(points && points.length != 0){
            for (var i = 0; i < points.length; i++) {
                var _task = points[i].trainTaskGroup
                for(var j=0;j<_task.length;j++){
                    if(_task[j].floor == opts.floor){
                        var marker = NGR.marker(_task[j].latlng,
                            {icon: ngrIcon('task', _task[j].taskStatus), riseOnHover: true});
                        //弹窗内容
                        var popcontent = markerPopContent('task', _task[j].taskStatus, _task[j])
                        marker.bindPopup(popcontent,{className:'popstationstatus'}).openPopup();
                        setPopTipsTask(marker,_task[j],opts.wangDiv) 
                        opts.layerGroup.addLayer(marker)    
                    }
                    
                }        
            }
            opts.map.addLayer(opts.layerGroup)
        }
    }
    //右侧 作业车次分类列表
    window.setTaskType=function(opts){
        var _data=opts.markerData
        var _html = $('<ul class="dobtngroup ptypebar"></ul>')
        if(_data && _data.length != 0 ){
            //对地图中图标数据的更新
            for (var k = 0; k < _data.length; k++) {
                var _val = _data[k].train
                var isNoExit = rightBar.every(function(v){
                    return v != _val
                })
                
                if(isNoExit){
                    if(mapCnt.length == 1){
                        var _trainPoints = _data[k].trainTaskGroup;
                        for(var m=0;m<_trainPoints.length;m++){
                            if(_trainPoints[m].floor == mapCnt[0].floor){
                                rightBar.push(_val);
                                break;
                            }    
                        }
                    }else{
                        rightBar.push(_val)
                    }
                } 
                
                
            }
            if(rightBarAcc.length == 0){
                if(rightBar.length != 0){
                    rightBarAcc=[rightBar[0]]    
                }
            }
            
        }
        //右侧数据渲染
        for(var i=0;i<rightBar.length;i++){
            $('<li class="ptype" data-ptype="'+rightBar[i]+'" style="margin-top:1rem"><span class="">'+rightBar[i]+'</span>'+'</li>').appendTo(_html)
        }
        _html.appendTo('.chartBar_right')
        //右侧状态更新
        $('.ptypebar .ptype').each(function(){
            var $this = $(this)
            $this.removeClass("acc")
            $this.find('span').removeClass('chartBarAct')
            for(var i=0;i<rightBarAcc.length;i++){
                if($this.data('ptype') == rightBarAcc[i]){
                    $this.addClass("acc")
                    $this.find('span').addClass('chartBarAct')
                }
            }
        })
        $('.ptypebar .ptype').click(function (e) {
            rightBarAcc = []
            var _val = $(this).data('ptype')
            rightBarAcc.push(_val)
            $('.ptypebar .ptype').each(function() {
                var $this = $(this)
                $this.removeClass("acc")
                $this.find('span').removeClass('chartBarAct')
                for(var i=0;i<rightBarAcc.length;i++){
                    if($this.data('ptype') == rightBarAcc[i]){
                        $this.addClass("acc")
                        $this.find('span').addClass('chartBarAct')
                    }
                }
            })
            for(var w=0;w<mapCnt.length;w++){
                //对地图中图标数据的更新
                addMarkersTask(mapCnt[w]);   
            }
        })      
    }
    */
    /*
    //生成 navigation
    window.navigationProvider = new NGR.NavigationProvider({
        appKey: '477fb7d9b9b0431fad887ea5af7fb703'
    });
*/
    /*
    function tempsHour(time){
        
        var _time = time;
        //console.log(_time)
        for(var w in qMonth){
            for(var m=0;m<qMonth[w].length;m++){
                if(qMonth[w][m] == _time){
                    return w
                    break;
                }
            }
        }
    }
    //整理点坐标，变为同一个格式(待删)
    window.getDataPoints = function (data) {
        var points = []
        for (var i = 0; i < data.length; i++) {
            var log = data[i].longitude ? data[i].longitude : (data[i].x ? data[i].x : "")
            var lat = data[i].latitude ? data[i].latitude : (data[i].y ? data[i].y : "")
            var dataInfo = {point: log + "," + lat, info: {}}
            for (var n in data[i]) {
                dataInfo.info[n] = data[i][n]
            }
            points.push(dataInfo)
        }
        return points
    }
*/
    /* 
    //右侧 岗位分类列表
    window.setStationType=function(opts){
        var _data=opts.markerData;
        if(_data && _data.length>0){
            //右侧列表数据生成
            for(var i=0;i<_data.length;i++){
                var typeText = _data[i].userPostType;
                var isNew = rightBar.every(function(v){
                    return v != typeText
                })
               if(isNew){
                   rightBar.push(typeText)
               }
            }        
        }
        //渲染右侧列表
        var imgurlM='./resource/map/images/';
        var _html = $('<ul class="dobtngroup ptypebar"></ul>')
        for(var m=0;m<rightBar.length;m++){
            $('<li class="ptype" data-ptype="'+rightBar[m]+'"><img src="'+imgurlM+getImgName(rightBar[m])+'" width="46"><span class="">'+rightBar[m]+'</span>'+'</li>').appendTo(_html)
        }
        _html.appendTo('.chartBar_right')
        //更新右侧列表的按钮状态（选中与否）
        $('.ptypebar .ptype').each(function() {
            var $this = $(this)
            $this.removeClass("acc")
            $this.find('span').removeClass('chartBarAct')
            for(var i=0;i<rightBarAcc.length;i++){
                if($this.data('ptype') == rightBarAcc[i]){
                    $this.addClass("acc")
                    $this.find('span').addClass('chartBarAct')
                }
            }
        })
        //事件绑定
        $('.ptypebar .ptype').click(function (e) {
            var _val = $(this).data('ptype')
            //判断右侧选中与否
            var isExit = rightBarAcc.some(function(v){
                return v == _val
            })
            if(isExit){
                var _tempArr=rightBarAcc.filter(function(vs){
                  return vs !=_val
                })
                rightBarAcc = _tempArr
                $(this).removeClass("acc")
                $(this).find('span').removeClass('chartBarAct')
            }else{
                rightBarAcc.push(_val)
                $(this).addClass("acc")
                $(this).find('span').addClass('chartBarAct')
            }
            for(var w=0;w<mapCnt.length;w++){
                //对地图中图标数据的更新
                addMarkers(mapCnt[w])   
            }
        })      
    }

    //右侧 设备分类列表
    window.setEquipmentType=function(opts){ 
        var _data=opts.markerData
        if(_data && _data.length > 0){
            //右侧列表数据生成
            for(var i=0;i<_data.length;i++){
                var typeText = _data[i].type;
                var isNew = rightBar.every(function(v){
                        return v != typeText
                    })
               if(isNew){
                   rightBar.push(typeText)
               }
            }
        }
        //渲染右侧列表
        var _html = $('<div class="chartBar_right_list eqtypebar"></div>')
        $('<span class="onlyec">仅显示异常设备</span>').appendTo(_html)
        for(var j=0;j<rightBar.length;j++){
            $('<span class="eqtype" data-eqtype="'+rightBar[j]+'">'+rightBar[j]+'</span>').appendTo(_html)
        }
        var tips = '<ul class="chartBar_exm"><li data-ptype="1"><img src="./resource/map/images/eqok.png" width="" /><span>正常</span></li><li data-ptype="2"><img src="./resource/map/images/eqcall.png" width="" /><span>报修</span></li><li data-ptype="3"><img src="./resource/map/images/eqing.png" width="" /><span>维修</span></li><li data-ptype="4"><img src="./resource/map/images/eqrecall.png" width="" /><span>验收</span></li></ul>'
        $(tips).appendTo(_html)
        _html.appendTo('.chartBar_right')
        //更新右侧列表的选中状态
        $('.eqtypebar .eqtype').each(function() {
            var $this = $(this)
            $this.removeClass('chartBarAct')
            for(var i=0;i<rightBarAcc.length;i++){
                if($this.data('eqtype') == rightBarAcc[i]){
                    $this.addClass('chartBarAct')
                }
            }
        })
        if(eqRepair){
            $('.onlyec').addClass('chartBarAct')
        }
        
        $('.eqtypebar .eqtype').click(function (e) {
            var $this = $(this)
            var _val = $(this).data('eqtype')
            var isNoAcc = rightBarAcc.every(function(v){
                return v != _val
            })
            if(isNoAcc){
                $this.addClass('chartBarAct')
                rightBarAcc.push(_val)    
            }else{
                $this.removeClass('chartBarAct')
                var _tempArr=rightBarAcc.filter(function(v){
                  return v !=_val
                })
                rightBarAcc = _tempArr
            }
            for(var w=0;w<mapCnt.length;w++){
                //对地图中图标数据的更新
                addMarkersEQ(mapCnt[w]);   
            }
        })
        $('.onlyec').click(function(){
            if($(this).hasClass('chartBarAct')){
                $(this).removeClass('chartBarAct')
                eqRepair = false
            }else{
                $(this).addClass('chartBarAct')
                eqRepair = true
            }
            for(var w=0;w<mapCnt.length;w++){
                //对地图中图标数据的更新
                addMarkersEQ(mapCnt[w]);   
            }
        })
    }
*/
    /*
    //右侧 量化分类列表
    window.setQuanType=function(opts){
        var tips = '<div class="chartBar_right_list quantypebar"><ul class="chartBar_exm"><li data-ptype="0"><p class="quanimg quanimg1"></p><span>无人巡视</span></li><li data-ptype="2"><p class="quanimg quanimg2"></p><span>正在巡视</span></li><li data-ptype="1"><p class="quanimg quanimg3"></p><span>完成巡视</span></li></ul></div>'
        $(tips).appendTo('.chartBar_right')
    }
    //经纬坐标转墨卡托
    window.latLng2WebMercator=function(latLng) {//[30.585748,114.32894]  
        var earthRad = 6378137.0;  
        var x = latLng[1] * Math.PI / 180 * earthRad;  
        var a = latLng[0] * Math.PI / 180;  
        var y = earthRad / 2 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));  
        //        return [y,x]; //[3579066.6894065146,12727039.383734727]  
        return {y:y,x:x}; //{y:3579066.6894065146,x:12727039.383734727]  
    } 
    //获取个人岗位详情的数据（作业状态或轨迹） 
    window.getDataWorkStation = function(opts){
	    isAjax = true 
        $('.chartBar_right2').show()
        if(isStation){
            var _stationType = accWorkerInfo.stationType
            var url=serverURL.basePath+serverURL.ststatusUrl;
            if(_stationType == "0"){
                url=serverURL.basePath+serverURL.ststatusUrl;
            }else if(_stationType == "1"){
                url=serverURL.basePath+serverURL.stmoveUrl;
            }
            var _data ={floor:opts.floor,
                        PID:accWorkerInfo.userId,
                        time:accWorkerInfo.time
                       }
            $.ajax({
                url:url,
                type:"get",
                data:_data,
                dataType:"json",
                success:function(res){
                    opts.layerGroup.clearLayers()//清除之前画上去的marker点
                    if(_stationType == "0"){
                        isMoving = false;
                        accWorkerInfo.receiveNum += Number(res.data.userInfo.receiveNum)
                        accWorkerInfo.successNum += Number(res.data.userInfo.successNum)
                        accWorkerInfo.lostNum += Number(res.data.userInfo.lostNum)
                        
                        opts.linelayerGroup.clearLayers()//清除之前画上去的polinly marker点
                        opts.markerData = res.data.location
                        addMarkersSTStatus(opts);    
                    }else if(_stationType == "1"){
                        isMoving = true;
                        opts.markerData = res.data.emLocation
                        addMarkersSTMoving(opts);
                    }
                    setStationDeTailType(res.data.info)
                },
                complete:function(){
                    if(RNum == mapCnt.length){
                        isAjax = false;
                        RNum = 1
                    }else{
                        RNum++
                    }
                }
            })
        }
    }
*/
    /*
    //将点数据按楼层分组（任务）
    function sepFloorDataTask(data,floorid){
        var _data=data,_floor=floorid
        var floorData = {}
        for(var i=0;i<_floorId.length;i++){
            floorData[_floorId[i]] = []
            for(var j=0;j<_data.length;j++){
                var _trainTaskGroup = _data[j].trainTaskGroup
                for(var k=0;k<_trainTaskGroup.length;k++){
                    if(_trainTaskGroup[k][_floor] == _floorId[i]){
                        floorData[_floorId[i]].push(_trainTaskGroup[k])         
                    }     
                }
                  
            }
            
        }
        return floorData
    }
*/
/*
    //生成地图请求
    function mapRequst(opts){
        var _res = opts.res;
        _res.requestMaps().then(function (maps) {
            _res.requestPOIChildren(maps.list[0].poi).then(function (floors) {
                console.log(floors)
                //loadPlanarGraph(opts)
            }).fail(function (e) {
                return console.error(e, e.stack);
            });
        }).fail(function (e) {
            return console.error(e, e.stack);
        });    
    }
*/ 
/*
    //生成岗位marker点添加到地图
    window.addMarkers = function (opts) {
        // NGR.canvasmarker([39.90613568135501,116.46073758602142],{}).addTo(map)
        var _data=opts.markerData,_opts=opts;
        var points = [];//实际点数据
        _opts.layerGroup.clearLayers()//清除之前画上去的marker点
        _opts.linelayerGroup.clearLayers()//清除之前画上去的line点
        
        if(rightBarAcc.length>0){
            for (var i = 0; i < _data.length; i++) {
                var _type = _data[i].userPostType;
                var _isExit=rightBarAcc.some(function(vv){
                    return vv == _type
                })
                if(_isExit){
                    points.push(_data[i])
                }
            }    
        }else{
            //如果没值显示全部
            points = _data
        } 
        if(points && points.length != 0){
            for (var i = 0; i < points.length; i++) {
                var marker = NGR.marker(points[i].latlng,
                    {icon: ngrIcon('worker', points[i].userPostType), riseOnHover: true});
                //弹窗内容
                var popcontent = markerPopContent('worker', 'workPosition', points[i])
                marker.bindPopup(popcontent, {className: 's'}).openPopup();
               setPopTips(marker,points[i],opts.wangDiv) 
               _opts.layerGroup.addLayer(marker)
            }
            _opts.map.addLayer(_opts.layerGroup)
        }
    }

    //生成设备点添加到地图
    window.addMarkersEQ = function (opts) {
        var _tempPoints = opts.markerData,_points=[]; 
        for(var k=0;k<_tempPoints.length;k++){
            if(_tempPoints != '正常'){
                _points.unshift(_tempPoints[k])
            }else{
                _points.push(_tempPoints[k])
            }
            
        }
        var _opts=opts;
        var points = [];//实际点数据
        _opts.layerGroup.clearLayers()//清除之前画上去的marker点
        _opts.linelayerGroup.clearLayers()//清除之前画上去的line点
        
        //对地图中图标数据的更新
        //不考虑“只显示故障设备”按钮
        var _tempMarkPoints=[];//_tempMarkPoints:选中的按钮对应的point点
        
        if(rightBarAcc.length != 0){
            for (var j = 0; j < _points.length; j++) {
                for (var k = 0; k < rightBarAcc.length; k++) {
                    if (_points[j].type == rightBarAcc[k]) {
                        _tempMarkPoints.push(_points[j]);
                        //break;
                    }
                }

            }    
        }else{
            _tempMarkPoints = _points
        }
        //考虑上“只显示故障设备”按钮；        
        if(eqRepair){
            //acc的话 points点先把问题点放进去
            var _unNormalPoints= _tempMarkPoints.filter(function(v){
                return v.status !== '正常'
            })//全部问题点
            _tempMarkPoints = _unNormalPoints
        }
	    //填充需要渲染的点
        for(var m=0;m<_tempMarkPoints.length;m++){
            var _point = _tempMarkPoints[m]
            var _latlng = _point.latlng
            
            var isNew = points.every(function(v,ids){
                return ((v.latlng[0] != _latlng[0]) || (v.latlng[1] != _latlng[1]))
            })
            
           if(isNew){
               points.push(_point)
           }
            
        }//加入正常点
        if(points && points.length != 0){
            var markers = new NGR.layerGroup()
            for (var i = 0; i < points.length; i++) {
                var marker = NGR.marker(points[i].latlng,
                    {icon: ngrIcon('eq', points[i].status)});
                //弹窗内容
                var popcontent = markerPopContent('eq', points[i].status, points[i])
                console.log(marker)
                marker.bindPopup(popcontent,{className:'s'}).openPopup();
                setPopTipsEQ(marker,null,opts.wangDiv)
                markers.addLayer(marker)
                
            }
            opts.layerGroup.addLayer(markers)
            opts.map.addLayer(opts.layerGroup)    
        }
        
    }
*/
/*
    //生成 navigation
    window.navigationProvider = new NGR.NavigationProvider({
        appKey: '477fb7d9b9b0431fad887ea5af7fb703'
    });
*/
/*
    //生成岗位行动轨迹点添加到地图 12-13
    window.addMarkersSTMoving = function(opts){
        var latlngs = []
        var points =[],allPoints = opts.markerData
        if(allPoints && allPoints.length != 0){

            if(opts.lastMovePointTime != 0){
                for(var w=allPoints.length-1;w>0;w--){
                    var _time = allPoints[w].addtime.replace(/-/g,'/')
                    var _lastMovePointTime = (new Date(_time).getTime())/1000
                    if(_lastMovePointTime >= opts.lastMovePointTime){
                        points.unshift(allPoints[w])
                    }
                }
            }else{
                points = allPoints
            }
            points = allPoints
            if(points && points.length > 1){
                if(opts.lastMovePoint != null){
                    opts.linelayerGroup.removeLayer(opts.lastMovePoint)   
                    opts.lastMovePoint = null
                }
                
                for(var i=0;i<points.length;i++){
                //    var _latlng = latLng2WebMercator(points[i].latlng)
                //    _latlng.planarGraphId = _floorId[mainFloor] 
                //    latlngs.push(_latlng)                
                //    if(latlngs.length > 1){
                //        var _latlng2 = latlngs[latlngs.length-1];
                //        var _latlng = latlngs[latlngs.length-2]; 
                //        var xitY=_latlng2[0]-_latlng[0];
                //        var xitX=_latlng2[1]-_latlng[1];
                //        var xitCount=5
                //        var xitMEX=(xitX/xitCount);
                //        var xitMEY=((xitY/xitCount));
                //        //for(var m=1;m<xitCount+1;m++){
                //            latlngs.splice(latlngs.length-1,0,[xitMEY+_latlng[0]+0.00001,(xitMEX+_latlng[1])],[xitMEY*2+_latlng[0]-0.00001,(xitMEX*2+_latlng[1])],[xitMEY*3+_latlng[0]+0.00001,(xitMEX*3+_latlng[1])],[xitMEY*4+_latlng[0]-0.00001,(xitMEX*4+_latlng[1])],[xitMEY*5+_latlng[0]+0.00001,(xitMEX*5+_latlng[1])]) 
                //            //console.log(latlngs)
                //        //}
                //    }
                    latlngs.push([Number(points[i].latlng[0]),Number(points[i].latlng[1])])
                    var _icontype = 'm'
                    if(i == 0){
                        if(opts.lastMovePointTime == 0){
                            _icontype = 'b'    
                        }
                    }else if(i == points.length-1){
                        var _time = points[i].addtime.replace(/-/g,'/')
                        opts.lastMovePointTime = (new Date(_time).getTime())/1000
                        _icontype = 'e'
                    }else{
                        _icontype = 'm'
                    }
                    var marker = NGR.marker(points[i].latlng,
                                {icon:ngrIcon('userM',_icontype)});
                    if(i == points.length-1){
                        opts.lastMovePoint = marker    
                    }
                    //弹窗内容
                    var popcontent = markerPopContent('userM','normal',points[i])
                    marker.bindPopup(popcontent,{className:'s'}).openPopup();
                    setPopTips('userM',marker,null,opts.wangDiv) 
                    opts.linelayerGroup.addLayer(marker)
                }
                var polyline = NGR.polyline(latlngs, { color: '#26e8e8',lineCap:'round',lineJoin:'round',weight: 3,dashArray: [5, 10],arrow:false,radius: 0.6})
                opts.linelayerGroup.addLayer(polyline)
                // 画轨迹
                //  navigationProvider.transitNavitage(latlngs).then(function (response) {
                //    naviReady = true;
                //    // 请求返回如果在地图第一次加载之后，则直接绘制导航线和经停点
                //    if (mapFirstLoad) {
                //      renderNaviLine(navigationProvider, _floorId[mainFloor], myStyle);
                //    }
                //  }).fail(onerror);


                opts.map.addLayer(opts.linelayerGroup)
                
                //map.fitBounds(polyline.getBounds())    
            }
            
        }
        $('#'+opts.mapElm).find('.lds-css').css('display','none')
    }
*/
/*
    //将点数据按楼层分组（轨迹）
    function sepFloorData(data,floorid){
        var _data=data,_floor=floorid
        var floorData = {}
        for(var i=0;i<_floorId.length;i++){
            floorData[_floorId[i]] = []
            for(var j=0;j<_data.length;j++){
                if(_data[j].floor == _floorId[i]){
                    floorData[_floorId[i]].push(_data[j])         
                }   
            }
            
        }
        return floorData
    }
*/ 
}).call(this, $);
